/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojo.hibernate;

/**
 *
 * @author kazim
 */
import utils.BaseDAO;
import java.util.List;

public class SubinstitutionmasterDAO extends BaseDAO {

    public void save(Subinstitutionmaster sim) {
        try {
            beginTransaction();
            getSession().save(sim);
            commitTransaction();
        } catch (RuntimeException re) {
            re.printStackTrace();
            throw re;
        }
    }

    public void update(Subinstitutionmaster sim) {
        try {
            beginTransaction();
            getSession().update(sim);
            commitTransaction();
        } catch (RuntimeException re) {
            re.printStackTrace();
            throw re;
        }
    }

    public void delete(Subinstitutionmaster sim) {
        try {
            beginTransaction();
            getSession().delete(sim);
            commitTransaction();
        } catch (RuntimeException re) {
            re.printStackTrace();
            throw re;
        }
    }

    public List<Subinstitutionmaster> findAll() {
        beginTransaction();
        List<Subinstitutionmaster> list = getSession().createQuery("select u from Subinstitutionmaster u").list();
        commitTransaction();
        return list;
    }

    public Subinstitutionmaster findBySimId(Integer simId) {
        beginTransaction();
        Subinstitutionmaster sim = new Subinstitutionmaster();
        sim = (Subinstitutionmaster) getSession().load(Subinstitutionmaster.class, simId);
        commitTransaction();
        return sim;
    }

    public List<Subinstitutionmaster> findBysimImId(short simImId) {
        beginTransaction();
        List<Subinstitutionmaster> list = getSession().createQuery("select u from Subinstitutionmaster u where u.institutionmaster.imId = :simImId").setParameter("simImId", simImId).list();
        commitTransaction();
        return list;
    }
}
